package com.dongdongshop.controller;

import com.dongdongshop.data.Result;
import com.dongdongshop.page.PageParms;
import com.dongdongshop.page.PageUtil;
import com.dongdongshop.service.SearchService;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.Arrays;


@RestController
@RequestMapping("search")
public class SearchController {
    @Autowired
    private SearchService searchService;
    //高级客户端
    @Autowired
    private RestHighLevelClient restHighLevelClient;
    /**
     * @param parms 参数
     * @return
     * @throws IOException
     */
    @PostMapping("getSearchByName")
    public Result getSearchByName(@RequestBody PageParms<String> parms) throws IOException {
        PageUtil pageUtil = searchService.getSearchByName(parms);
        return Result.OK().setData(pageUtil);
    }



}
